package com.system.weirdor.www.controller;

import com.google.common.collect.Maps;
import com.system.weirdor.common.advice.BaseController;
import com.system.weirdor.common.utills.CamelNameUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

/**
 * Created by weirdor on 2017/8/23.
 */
@Controller
public class HomeController extends BaseController {

    @RequestMapping(value = "/module/{module}/list")
    public ModelAndView moduleList(@PathVariable("module") String module){
        Map<String,Object> context = Maps.newHashMap();
        context.put("module", module);
        String view = "/pages/module/"+StringUtils.trim(CamelNameUtils.camelToUnderline(module))+"/" + StringUtils.trim(CamelNameUtils.camelToUnderline(module)) + "_list";
        return new ModelAndView(view, context);
    }

    @RequestMapping(value = "/module/{module}/edit")
    public ModelAndView moduleEdit(@PathVariable("module") String module){
        Map<String,Object> context = Maps.newHashMap();
        context.put("module", module);
        String view = "/pages/module/"+StringUtils.trim(CamelNameUtils.camelToUnderline(module))+"/" + StringUtils.trim(CamelNameUtils.camelToUnderline(module)) + "_edit";
        return new ModelAndView(view, context);
    }
}
